package com.zut.oss.service;


import com.zut.oss.adapter.StorageAdapter;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

//防腐层
@Service
public class FileService {



    private StorageAdapter storageAdapter;

    public FileService (StorageAdapter storageAdapter){

        this.storageAdapter = storageAdapter;
    }
    public List<String> getAllBucket(){
        return storageAdapter.getAllBucket();
    }

    public String upLoad(MultipartFile multipartFile, String bucket, String ObjectName){
        storageAdapter.uploadBucket(multipartFile, bucket,ObjectName);
        String url = storageAdapter.getUrl(bucket, ObjectName);
        //返回值为文件的地址
        return url;

    }


    public String getUrl(String bucketName, String objectName) {

        return storageAdapter.getUrl(bucketName,objectName);
    }
}
